package com.zxy.ziems.server.classify.convertor;

import com.zxy.ziems.server.classify.pojo.dto.ClassifyDevicePropertyDTO;
import com.zxy.ziems.server.classify.pojo.vo.ClassifyDevicePropertyVO;
import com.zxy.ziems.server.classify.pojo.vo.ClassifyVO;
import com.zxy.ziems.server.device.pojo.entity.DataTypeEntity;
import com.zxy.ziems.server.device.pojo.entity.DataUnitEntity;
import com.zxy.ziems.server.device.pojo.entity.DeviceEntity;
import com.zxy.ziems.server.classify.pojo.entity.Classify;
import com.zxy.ziems.server.classify.pojo.entity.ClassifyDeviceProperty;
import com.zxy.ziems.server.domain.Org;
import com.zxy.ziems.server.classify.pojo.dto.ClassifyDto;
import com.zxy.ziems.server.scene.pojo.entity.SceneEntity;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * @description:
 * @auther: windrunner
 * @date 2022/9/1 18:45
 */
@Mapper
public interface ClassifyConvert {

    ClassifyConvert INSTANCE = Mappers.getMapper(ClassifyConvert.class);

    Classify classifyDtoToClassify(ClassifyDto classifyDto);

    @Mapping(target = "unitId", source = "unit.id")
    @Mapping(target = "unit", source = "unit.name")
    @Mapping(target = "multiple", source = "entity.multiple")
    ClassifyVO classifyDO2ClassifyVO(Classify entity, DataUnitEntity unit);


    @Mapping(target = "id", source = "dto.id")
    @Mapping(target = "deviceType", source = "deviceEntity.typeCode")
    ClassifyDeviceProperty classifyDevicePropertyDto2Do(ClassifyDevicePropertyDTO dto, DeviceEntity deviceEntity);


    @Mapping(target = "id", source = "entity.id")
    @Mapping(target = "deviceId", source = "deviceEntity.id")
    @Mapping(target = "deviceName", source = "deviceEntity.name")
    @Mapping(target = "deviceCode", source = "deviceEntity.code")
    @Mapping(target = "buildingName", source = "building.name")
    @Mapping(target = "floorName", source = "floor.name")
    @Mapping(target = "classifyId", source = "classify.classifyId")
    @Mapping(target = "classifyName", source = "classify.classifyName")
    @Mapping(target = "multiple", source = "entity.multiple")
    @Mapping(target = "dataTypeId", source = "dataType.id")
    @Mapping(target = "dataTypeName", source = "dataType.name")
    ClassifyDevicePropertyVO classifyDevicePropertyDO2VO(ClassifyDeviceProperty entity,
                                                         Classify classify,
                                                         DeviceEntity deviceEntity,
                                                         SceneEntity building,
                                                         SceneEntity floor,
                                                         Org org, DataTypeEntity dataType);

}
